home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / ShellTView.h < prev    next >
C/C++ Source or Header  |  1992-06-29  |  3KB  |  110 lines

  1. #ifndef ShellTView_First
  2. #ifdef __GNUG__
  3. //pragma once
  4. #pragma interface
  5. #endif
  6. #define ShellTView_First
  7.  
  8. #include "TextView.h"
  9. #include "PttyConnection.h"
  10. #include "CmdNo.h"
  11.  
  12. extern Rectangle gShellTextViewRect;
  13. extern char *gDefaultArgv[];
  14.  
  15. //---- ShellTextView --------------------------------------------------------
  16. // a TextView connected to a ptty running a shell
  17.  
  18. class ShellTextView: public TextView {
  19. public:
  20.     MetaDef(ShellTextView);
  21.  
  22.     ShellTextView(
  23.     EvtHandler *eh, Rectangle r, Text *t, 
  24.     char *name= 0, char **args= 0, bool becomeconsole= FALSE, 
  25.     TextViewFlags= eTextViewDefault, Point border= gBorder
  26.     );
  27.     
  28.     ~ShellTextView();
  29.     virtual  char *GetTermCap();
  30.     virtual  char *GetTerm();
  31.     
  32.     virtual void BecomeConsole();
  33.     
  34.     virtual void Received();
  35.     virtual void Submit(char *buf, int size); 
  36.     virtual void SubmitInterrupt(char c); 
  37.     virtual bool IsIdle();
  38.     virtual void Reconnect();
  39.     virtual void Start(char *name= 0, char **args= 0, bool becomeconsole= FALSE);
  40.     virtual void Done(); 
  41.     virtual void SlaveDied();
  42.     virtual void CleanupDeath();
  43.     
  44.     virtual Command *CntrlChar(byte b);   
  45.     virtual void DoReveal(bool);    
  46.     virtual void RevealOutput(Rectangle r, Point p);
  47.     void Draw(Rectangle);      // draw output cursor
  48.     Text *SetText(Text *, bool scroll= cRevealTop);     // returns old text       
  49.     void SetTtySize(int rows, int cols);
  50.     void SetTtySize(Rectangle r, Font *fd);
  51.     void ChangedViewRect(Rectangle r);
  52.  
  53.     char **GetArgv();
  54.     class PttyConnection *GetPtty();
  55.     void ClearOutput();
  56.     void Doit();
  57.     void SetMaxLogSize(int n);
  58.     Command *TtyInput(char *buf, int len= -1); // appends buf to ttys input queue
  59.  
  60.     //---- overridden to maintain a fence of read only text
  61.     bool DeleteRequest(int from, int to);
  62.     void Paste(Text *insert);
  63.     
  64.     //---- controller methods 
  65.     Command *DoKeyCommand(int, Token); 
  66.     static Menu* MakeMenu(int menuId);
  67.     void DoSetupMenu(class Menu *);
  68.     Command *DoMenuCommand(int);
  69.     void SelectAll(bool redraw);
  70.     
  71.     //---- input/output
  72.     OStream& PrintOn(OStream&);
  73.     IStream& ReadFrom(IStream&);
  74.     
  75. protected:
  76.     class GapText *noEchoBuffer;  // used when echo is turned off
  77.     int lastSubmit;
  78.     int maxLogSize;
  79.     int state;          // for interpreting ESC-Sequences
  80.     bool pendingCR;     
  81.     PttyChars pttyc;    // tty-chararacters that submit a command
  82.     char *pttycstr;
  83.     char **argv;
  84.     byte *linebuf;
  85.  
  86.     void Init(bool doReveal, char *name, char **argv, bool cons);
  87.     void Term();
  88.     bool ModifiesReadOnly();
  89.     void Wrap();
  90.     void BackSpace(Text *t, int n);
  91.     void CarriageReturn(Text *t);
  92.     void MarksToEOT();
  93.     void DrawOutputCursor(Point p);
  94.     void FlushPendingInput();
  95.     bool HandleSpecialOutChar(char p, class GapText *);
  96.     virtual void ProcessOutput(GapText *t, char *buf, int size);
  97.     virtual void InsertReceivedText(Text *t, int from, int to);
  98.  
  99. private:
  100.     class PttyInputHandler *pttyinp;
  101.     class ShellZombieHandler *zombieHandler;
  102.     class PttyConnection *pttycon;
  103.     class Mark *outputCursor, *inputCursor;
  104.     class OrdCollection *inpQueue;
  105.     bool doReveal;
  106.     bool inReceive;
  107. };
  108.  
  109. #endif  
  110.